package com.blue.excel.model;

import org.apache.poi.hssf.usermodel.HSSFCellStyle;
import org.apache.poi.ss.usermodel.CellStyle;

/**
 * Created by ChenYaHui on 2017/8/8.
 */
public class CellStyleInfo {
    public short fillForegroundColor = 64;
    public short fillPattern;
    public short borderTop;
    public short borderRight;
    public short borderBottom;
    public short borderLeft;
    public short alignment;
    public short verticalAlignment = HSSFCellStyle.VERTICAL_CENTER;
    public short dataFormat;

    public CellStyleInfo() {

    }

    public CellStyleInfo(CellStyle cellStyle) {
        this.fillForegroundColor = cellStyle.getFillForegroundColor();
        this.fillPattern = cellStyle.getFillPattern();
        this.borderTop = cellStyle.getBorderTop();
        this.borderRight = cellStyle.getBorderRight();
        this.borderBottom = cellStyle.getBorderBottom();
        this.borderLeft = cellStyle.getBorderLeft();
        this.alignment = cellStyle.getAlignment();
        this.dataFormat = cellStyle.getDataFormat();
    }



    public CellStyleInfo(short alignment) {
        this.alignment = alignment;
    }

    public CellStyleInfo(short fillForegroundColor,short alignment) {
        setFillForegroundColor(fillForegroundColor);
        this.alignment = alignment;
    }

    public void setBorderAll(short i){
        borderTop = i;
        borderRight = i;
        borderBottom = i;
        borderLeft = i;
    }

    public void setFillForegroundColor(short i){
        fillForegroundColor = i;
        fillPattern = HSSFCellStyle.SOLID_FOREGROUND;
        setBorderAll(HSSFCellStyle.BORDER_THIN);
    }

    public void setAlignment(short i){
        alignment = i;
    }

    public void setDataFormat(short i){
        this.dataFormat = i;
    }

    public boolean match(CellStyle cellStyle){
        return cellStyle.getAlignment() == this.alignment && cellStyle.getVerticalAlignment() == this.verticalAlignment &&
                cellStyle.getBorderTop() == this.borderTop && cellStyle.getBorderRight() == this.borderRight &&
                cellStyle.getBorderBottom() == this.borderBottom && cellStyle.getBorderLeft() == this.borderLeft &&
                cellStyle.getFillForegroundColor() == this.fillForegroundColor && cellStyle.getFillPattern() == this.fillPattern &&
                cellStyle.getDataFormat() == this.dataFormat;
    }



}
